package com.itheima.mapper;

import com.itheima.VO.SetMealCountVO;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;

@Mapper
public interface SetmealMapper{

    List<Setmeal> findAll(Setmeal setmeal);


    void add(Setmeal setmeal);

    Setmeal findById(Integer id);

    /**
     * 查询总记录数
     * @return
     */
    @Select("select count(*)from t_setmeal")
    Long count();

    /**
     * 分页查询
     * @param begin
     * @param pageSize
     * @return
     */
    @Select("select * from t_setmeal limit #{begin},#{pageSize}")
     List<Setmeal> page(Integer begin,Integer pageSize);

    void edit(Setmeal setmeal);


    @Select("select * from t_setmeal")
     List<Setmeal> getname();

    @Select("SELECT COUNT(*) AS count\n" +
            "FROM t_order\n" +
            "WHERE setmeal_id = #{id}")
    Integer getReservationsTotal(Integer id);

    @Select("select count(*) from t_order")
    Integer TotalSize();

    @Select("select id,name from t_setmeal")
    List<Setmeal> getsetmealname();


    @Select("SELECT COUNT(*) AS count\n" +
            "FROM t_order\n" +
            "WHERE setmeal_id = #{id}")
    List<SetMealCountVO> getsetmealcount(Integer id);

    @Select("select * from t_setmeal")
    Setmeal findAllempty();
}
